unit Filtered;

interface

uses
  Database,
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, ComCtrls, DB, Grids, Menus, ExtCtrls, DBGrids;

type
  TFormFiltered = class(TForm)
    PopupMenu: TPopupMenu;
    MenuStayOnTop: TMenuItem;
    PanelBase: TPanel;
    PanelBase2: TPanel;
    BtnDelete: TBitBtn;
    PanelMain: TPanel;
    BtnHelp: TBitBtn;
    MemoText: TMemo;
    BtnClear: TBitBtn;
    MainMenu: TMainMenu;
    MenuMain: TMenuItem;
    MenuEscape: TMenuItem;
    MenuHelp: TMenuItem;
    MenuCtrlTab: TMenuItem;
    MenuCtrlTab2: TMenuItem;
    MenuAutotyper: TMenuItem;
    MenuChat: TMenuItem;
    MenuTell: TMenuItem;
    MenuStatus: TMenuItem;
    MenuMessage: TMenuItem;
    MenuImagery: TMenuItem;
    MenuExit: TMenuItem;
    MenuPanic: TMenuItem;
    MenuFToolbar: TMenuItem;
    MenuVariables: TMenuItem;
    MenuMap: TMenuItem;
    Data1: TMenuItem;
    Canvas1: TMenuItem;
    Panel1: TPanel;
    Status: TLabel;
    DSFiltered: TDataSource;
    GridFilters: TDBGrid;
    procedure BtnHelpClick(Sender: TObject);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure DSFilteredDataChange(Sender: TObject; Field: TField);
    procedure BtnDeleteClick(Sender: TObject);
    procedure MenuStayOnTopClick(Sender: TObject);
    procedure BtnClearClick(Sender: TObject);
    procedure MenuAutotyperClick(Sender: TObject);
    procedure MenuCtrlTabClick(Sender: TObject);
    procedure MenuEscapeClick(Sender: TObject);
    procedure MenuExitClick(Sender: TObject);
    procedure MenuPanicClick(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
    procedure WMGetMinMaxInfo(var MSG: Tmessage); message WM_GETMINMAXINFO;
  public
    { Public declarations }
  end;

var
  FormFiltered: TFormFiltered;

implementation

uses Main;

{$R *.DFM}

procedure TFormFiltered.WMGetMinMaxInfo(var MSG: Tmessage);
begin
  inherited;
  with PMinMaxInfo(MSG.lparam)^ do begin
    with ptMinTrackSize do begin
      X := 250;
      Y := 200;
    end;
    with ptMaxTrackSize do begin
      X := 9999;
      Y := 9999;
    end;
  end;
end;

procedure TFormFiltered.BtnHelpClick(Sender: TObject);
begin
  Datawell.Help('filtered_text');
end;

procedure TFormFiltered.FormMouseMove(Sender: TObject; Shift: TShiftState;
  X, Y: Integer);
begin
  Status.caption:=' '+(sender as TControl).hint;
end;

procedure TFormFiltered.DSFilteredDataChange(Sender: TObject;
  Field: TField);
begin
  MemoText.lines.clear;
  MemoText.text:=Datawell.TableFiltered.fieldbyname('Text').asstring;
end;

procedure TFormFiltered.BtnDeleteClick(Sender: TObject);
begin
  Datawell.DeleteFiltered;
end;

procedure TFormFiltered.BtnClearClick(Sender: TObject);
begin
  Datawell.ClearFiltered;
end;

procedure TFormFiltered.MenuStayOnTopClick(Sender: TObject);
begin
  TMenuItem(sender).checked:=not TMenuItem(sender).checked;
  if MenuStayOnTop.checked = true then formstyle:=fsstayontop
  else formstyle:=fsnormal;
end;

procedure TFormFiltered.MenuAutotyperClick(Sender: TObject);
begin
  FormMain.OpenFloater(TComponent(sender).tag);
end;

procedure TFormFiltered.MenuCtrlTabClick(Sender: TObject);
begin
  if TMenuItem(sender).tag = 0 then FormMain.NextScreen(8)
  else FormMain.PriorScreen(8);
end;

procedure TFormFiltered.MenuEscapeClick(Sender: TObject);
begin
  FormMain.show;
end;

procedure TFormFiltered.MenuExitClick(Sender: TObject);
begin
  close;
end;

procedure TFormFiltered.MenuPanicClick(Sender: TObject);
begin
  FormMain.MenuPanic.click;
end;

procedure TFormFiltered.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (key = VK_DELETE) and (activecontrol = GridFilters) then begin
    BtnDelete.click;
    key:=0;
  end;
end;

procedure TFormFiltered.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  FormMain.UnloadScreen(6);
end;

end.
